package V004_MouseClickInspect;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

/**
 *
 * @author Smai
 */
public class ActionListener implements KeyListener, MouseListener, MouseMotionListener {

  private Map map;

  public boolean arrowUp;
  public boolean arrowDown;
  public boolean arrowLeft;
  public boolean arrowRight;
  public int mouseX;
  public int mouseY;

  public void setActionListener(Map map){
    this.map = map;
  }

  @Override
  public void keyTyped(KeyEvent e) {
  }

  @Override
  public void keyPressed(KeyEvent e) {
    switch (e.getKeyCode()) {
      case KeyEvent.VK_UP:
        arrowUp = true;
        break;

      case KeyEvent.VK_DOWN:
        arrowDown = true;
        break;

      case KeyEvent.VK_LEFT:
        arrowLeft = true;
        break;

      case KeyEvent.VK_RIGHT:
        arrowRight = true;
        break;

      default:
        break;
    }
  }

  @Override
  public void keyReleased(KeyEvent e) {
    switch (e.getKeyCode()) {
      case KeyEvent.VK_UP:
        arrowUp = false;
        break;

      case KeyEvent.VK_DOWN:
        arrowDown = false;
        break;

      case KeyEvent.VK_LEFT:
        arrowLeft = false;
        break;

      case KeyEvent.VK_RIGHT:
        arrowRight = false;
        break;

      default:
        break;
    }
  }

  public void mouseClicked(MouseEvent e) {
  }

  public void mousePressed(MouseEvent e) {
    map.checkMouseInfo(e.getX(),e.getY());
  }

  public void mouseReleased(MouseEvent e) {
  }

  public void mouseEntered(MouseEvent e) {
  }

  public void mouseExited(MouseEvent e) {
  }

  public void mouseDragged(MouseEvent e) {
  }

  public void mouseMoved(MouseEvent e) {
    mouseX = e.getX();
    mouseY = e.getY();
  }
}
